import java.util.Arrays;
import java.util.Random;

public class TestSort {

    public static void order(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i]=i;
        }
    }
    //生成逆序数据
    public static void notOrder(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i]= array.length-i;
        }
    }
    //生成乱序数据
    public static void randomOrder(int[] array){
        Random random=new Random();
        for (int i = 0; i < array.length; i++) {
            array[i]=random.nextInt(10_0000);
        }
    }
    //测试排序用时
    public static void testInsertSort(int[] array){
        array=Arrays.copyOf(array,array.length);

        long startTime=System.currentTimeMillis();//单位:毫秒
        Sort.insertSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("插入排序耗时:"+(endTime-startTime));
    }

    public static void testShellSort(int[] array){
        array=Arrays.copyOf(array,array.length);

        long startTime=System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("希尔排序耗时:"+(endTime-startTime));
    }

    public static void main1(String[] args) {
        int[] array=new int[10_0000];
        notOrder(array);
        testInsertSort(array);
        testShellSort(array);
    }

    public static void main(String[] args) {
        int[] array={13,3,7,1,4,9,7,8};
        Sort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}
